<?php
/**
 * ===============================================
 * 版权所有 2019-2050 青岛铁锤科技有限公司，并保留所有权利。
 * 网站地址: http://www.huaxianling.com
 * ===============================================
 * Author: Alex
 * Created Time: 2019/8/11 12:17
 * Modified Time: 2019/8/11 12:17
 * Version: 2.0
 */
namespace App\Modules\System\Repositories;
use App\Models\Video;
use Flower\Core\Repository\Eloquent\BaseRepository;
class VideoRepository extends BaseRepository
{
    /**
     * Specify Model class name
     *
     * @return string
     */
    public function model()
    {
       return Video::class;
    }


	/**
	 * 插入数据
	 * @param $video
	 * @return array|mixed
	 */
    public function insertData($video){
    	if(is_array($video)){
    		$res = array_map(function ($v){
    			$videoInfo = $this->create([
				    'name'  => '视频',
				    'url'   => $v,
				    'thumb' => $v . '?x-oss-process=video/snapshot,t_1,f_jpg,m_fast'
			    ]);
    			return $videoInfo->id;
		    },$video);
	    }else {
		    $videoInfo = $this->create([
			    'name'  => '视频',
			    'url'   => $video,
			    'thumb' => $video . '?x-oss-process=video/snapshot,t_1,f_jpg,m_fast'
		    ]);
		    $res = $videoInfo->id;
	    }
    	return $res;
    }
}